Fix batch size handling in DatasetTorch to ensure at least one batch per file#66
Merged
AlexanderFengler merged 7 commits intomainfrom Jan 4, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Member
AlexanderFengler
left a comment
There was a problem hiding this comment.
Left a few thoughts thanks @cpaniaguam.
Definitely wasn't in good shape (not robust) before.
Thanks for looking into it.
…y samples per file
AlexanderFengler
approved these changes
Jan 4, 2026
Member
AlexanderFengler
left a comment
There was a problem hiding this comment.
Some of the batch-size choices in the tests seem a bit crazy now, but let's roll with it :). Thanks @copilot
|
@AlexanderFengler I've opened a new pull request, #68, to work on those changes. Once the pull request is ready, I'll request review from you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and bug fixes to the
DatasetTorchclass and its usage, focusing on batch size handling, error checking, and test consistency. The main changes enforce that the batch size must evenly divide the number of samples per file, update the logic for calculating batches per file, and update tests and configuration to use consistent, valid batch sizes.Core logic and validation improvements:
DatasetTorchto raise aValueErrorifbatch_sizedoes not evenly divide the number of samples per file, ensuring data consistency and preventing subtle bugs during batching.__getitem__, improving code clarity and reliability.Test updates and coverage:
tests/test_torch_mlp.pyto use batch sizes that evenly divide the sample count, and added a new test to verify that an error is raised if this condition is not met. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Configuration and constants alignment:
Minor code cleanups:
.keys()with directinchecks for dictionary membership throughout the code for improved readability and Pythonic style. [1] [2] [3]